package Controller;

import org.jgroups.JChannel;
import org.jgroups.Message;
import org.jgroups.ReceiverAdapter;
import org.jgroups.View;

public class ServerController extends ReceiverAdapter {

	JChannel chatControlCluster;

	public ServerController() {

		try {

			System.setProperty("jgroups.bind_addr", "127.0.0.1" );
			chatControlCluster = new JChannel();
			chatControlCluster.connect("chatControlCluster");
		

			
			System.out.println("egz	egzeg");
		

			chatControlCluster.setReceiver(this);
			
			Message msg = new Message();
			msg.setObject("Server message");
			chatControlCluster.send(msg);
			

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void viewAccepted(View new_view) {

	}

	public void receive(Message msg) {
		String mess = (String) msg.getObject();
		System.out.println("received : " + mess);
		if (mess.startsWith("|")) {

		}
	}

	/*
	 * public void receive(Message msg){
	 * 
	 * String message = (String)msg.getObject(); System.out.println("Message" +
	 * message);
	 * 
	 * 
	 * }
	 */

}
